#!/usr/bin/env php
<?php

require_once(__DIR__.'../../mini.php');

$argv = Mini::parse_cli_args($argv); 

if ((count($argv) == 1 && count($argv['input']) == 1) || isset($argv['h']) || isset($argv['help'])) {
    help();
    exit();
}

if (isset($argv['p']) || isset($argv['pretend'])) {
    define('MINI_PRETEND', true);
}

if (isset($argv['s']) || isset($argv['skip'])) {
    define('MINI_SKIP', true);
}

if (count($argv['input']) > 1) {
    array_shift($argv['input']);
    Task::run($argv['input'], $argv);
}

function help() {
    print <<<OUTPUT
Usage: 
    mini task1 [task2 [...]] [options]

Description:
    The 'mini' command is used to call the available tasks that can be used to
    speed up your development using mini framework.
    
Arguments: 
    task1 [task2 [...]]                 Run a single task or a list of tasks.
    list                                List the available tasks.
    help task1                          Display help information on the task.
    
Options: 
    -h, --help                          Shows this help message and quit.
    -p, --pretend                       Run but do not make any changes.
    -s, --skip                          Skip files that already exist.
    
Example:
    ex. mini create_new_project blog
    This will create a new project called blog under the current directory.

    ex. mini list
    This will list all of the available tasks that you can run.
    
    ex. mini help update_models
    This will display the help information on what does this task do.

    ex. mini update_models update_config
    This will call the update_models and update_config task.

    ex. mini migrate --previous
    This will migrate to the previous state of the schema.

OUTPUT;
}